package org.jbit.news.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.jbit.news.dao.BaseDao;
import org.jbit.news.dao.UserDao;
import org.jbit.news.entity.User;

public class UserDaoImpl extends BaseDao implements UserDao{

	public User findUser(String uname, String password) {
		String sql="select * from news_users where uname=? and upwd=?";
		Object[] objects={uname,password};
		ResultSet rs = this.exxcuteQuery(sql,objects);
		User user=null;
		try {
			while(rs.next()){
				user=new User();
				user.setUid(String.valueOf(rs.getObject(1)));
				user.setUname(String.valueOf(rs.getObject(2)));
				user.setUpwd(String.valueOf(rs.getObject(3)));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			closeAll(connection, pstmt, rs);
		}
		return user;
	}

}
